<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<c:set var="webroot" value="${pageContext.request.contextPath}" />
<html>
<head>
	<meta charset="utf-8">
	<title>还款日志</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${webroot}/static/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${webroot}/static/css/public.css" media="all" />
<style type="text/css">
.layui-table-view {
   height: 92% !important;
   
} 
.layui-table-body {
   height: 72% !important;
}
</style>
</head>
<body class="childrenBody">
<form class="layui-form">
    <input type="hidden" id="id" value="${id}">
    <form class="layui-form" id="filterForm">
       <div class="layui-inline" style="font-size: medium; padding: 0px 0px 6px;">
			费用合计:<span style="color: red;" id="totalMoney">0</span>元
	   </div>
    </form>
	<table id="newsList" lay-filter="newsList"></table>
	<!--审核状态-->
	<script type="text/html" id="newsStatus">
		{{#  if(d.newsStatus == "1"){ }}
		<span class="layui-red">等待审核</span>
		{{#  } else if(d.newsStatus == "0"){ }}
		<span class="layui-blue">已存草稿</span>
		{{#  } else { }}
			审核通过
		{{#  }}}
	</script>

	<!--操作-->
	<script type="text/html" id="newsListBar">
        <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="look">权限设置</a>
		<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
	</script>
</form>
<script type="text/javascript" src="${webroot}/static/layui/layui.js"></script>
<script src="${webroot}/static/js/jquery.min.js" charset="utf-8"></script>
<script>
layui.use(['form','layer','laydate','table','laytpl'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        laydate = layui.laydate,
        laytpl = layui.laytpl,
        table = layui.table;

    //新闻列表
    var tableIns = table.render({
        elem: '#newsList',
        url : '/admin/borrowlog/querypage?id='+$("#id").val(),
        cellMinWidth : 95,
        page : true,
        height : "full-125",
        limit : 5,
        limits : [ 10, 15, 20, 25 ,30 , 50, 80, 100],
        id : "newsListTable",
        cols : [[
            {field: 'createTime', title: '操作时间', sort: false,fixed:false, align:'center',templet : function(d) {
	           return layui.laytpl.toDateString(d.createTime,'yyyy-MM-dd');}},
            {field: 'initStatus', title: '原始状态', align:"center",templet : function(d){
            	if(d.initStatus == 1){
            	    return "已结清";
				}else if(d.initStatus == 2){
					return "未到期";
				}else if(d.initStatus == 3){
					return "逾期";
				}else if(d.initStatus == 4){
					return "展期";
				}else if(d.initStatus == 5){
					return "售后";
				}
            }},
            {field: 'upStatus', title: '更改状态', align:'center',templet : function(d){
            	if(d.upStatus == 1){
            	    return "已结清";
				}else if(d.upStatus == 2){
					return "未到期";
				}else if(d.upStatus == 3){
					return "逾期";
				}else if(d.upStatus == 4){
					return "展期";
				}else if(d.upStatus == 5){
					return "售后";
				}
            }},
            {field: 'periodMoney', title: '费用', align:'center',templet : function(d){
            	if(d.sumMoney != null){
            		$("#totalMoney").text(d.sumMoney);
            	}
            	if(d.periodMoney == null){
            	    return "";
				}else{
					return d.periodMoney;
				}
            }}
        ]]
    });
    
    //搜索【此功能需要后台配合，所以暂时没有动态效果演示】
    $(".search_btn").on("click",function(){
         table.reload("newsListTable",{
              page: {
                    curr: 1 //重新从第 1 页开始
              }
         });
    });

 
	// 时间戳的处理
	layui.laytpl.toDateString = function(d, format) {
		var date = new Date(d || new Date()), ymd = [
				this.digit(date.getFullYear(), 4),
				this.digit(date.getMonth() + 1),
				this.digit(date.getDate()) ], hms = [
				this.digit(date.getHours()),
				this.digit(date.getMinutes()),
				this.digit(date.getSeconds()) ];

		return format.replace(/yyyy/g, ymd[0]).replace(
				/MM/g, ymd[1]).replace(/dd/g, ymd[2])
				.replace(/HH/g, hms[0]).replace(/mm/g,
						hms[1]).replace(/ss/g, hms[2]);
	};
	// 数字前置补零
	layui.laytpl.digit = function(num, length, end) {
		var str = '';
		num = String(num);
		length = length || 2;
		for (var i = num.length; i < length; i++) {
			str += '0';
		}
		return num < Math.pow(10, length) ? str
				+ (num | 0) : num;
	};   

})
</script>
</body>
</html>